<?php

/**
 * @file cefiro.php
 * @brief Definiciones (macros) y archivos de cabecera (headers) constantes para todos los elementos del widget
 * @brief Tambien inicia la variable $smarty
 * @author DyrTechnologies
 * @version V 1.0
 * @date Wed Oct 03 2007
 *
 *  Part of the CEFIRO dynamic web framework project
 *
 *  Copyright (C) 2007  Dyr technologies http://dyrtech.com.ve
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


/**
 * @brief These 4 constants should be defined in the main project (in this case
 * sigelab), cefiro then will adjust the corresponding paths.
 * if (!defined('HOME')) define("HOME","sigelab");
 * if (!defined('ROOT')) define("ROOT",substr(__FILE__,0,strrpos(__FILE__,HOME)));
 * if (!defined('CEFIRO')) define("CEFIRO",ROOT."cefiro/widgets/cefiro.php");
 * if (!defined('TMP')) define ("TMP","C:\\xampp\\tmp");
 *
 * only the first (HOME) and  last (TMP) of those are here to set accordingly:
 */
if (!defined('HOME')) define ("HOME","sigelab");

$base = substr(__FILE__,0,strpos(__FILE__,'cefiro'));
if (strlen($base) == 0)
  $base = substr(__FILE__,0,strrpos(__FILE__,HOME));
if (!defined('ROOT')) define("ROOT",$base);
if (!defined('CEF_PATH')) define("CEF_PATH",ROOT."cefiro/widgets/");

if (!defined('TMP')) {
  if (@is_writable("/tmp"))
    define ("TMP","/tmp/");
  elseif (@is_writable("C:\\xampp\\tmp"))
    define ("TMP","C:\\xampp\\tmp");
  else
    define ("TMP",ROOT.HOME."/tmp/");
}

require_once(dirname(__FILE__).'/cef_def.php');
require_once(dirname(__FILE__).'/extra_apps.php');

$BASE_URL=getURL();
$base = substr($BASE_URL,0,strpos($BASE_URL,'cefiro'));
if (strlen($base) == 0)
  $base = substr($BASE_URL,0,strrpos($BASE_URL,HOME));
define("BASE_URL",$base);
define("FULL_URL",$base."cefiro/widgets/");

/**
 * @brief Asignacion de Parametros Smarty
 */
if(!isset($smarty)){
  require_once('Smarty.class.php');
	$smarty = new Smarty;
	$smarty->compile_dir = TMP;
	$smarty->config_dir = TMP;
	$smarty->cache_dir = TMP;
}

/**
 * tableWrap
 * Utility function to wrap a widget inside a table
 *
 * @param String $content
 * @return String wrapped content.
 */
function tableWrap($content){
  return '<table><tr>'.$content.'</tr></table>';
}

function tableNcellWrap($content){
  return '<table><tr><td>'.$content.'</td></tr></table>';
}
?>